﻿@using Project.Constraints.UI.Flyout
@using Project.Constraints.UI.Form
@using MT.Toolkit.StringExtension;
@inherits DialogTemplate<UserPwd>

@if (options != null)
{
    @UI.BuildForm(options)
}

@code {
    FormOptions<UserPwd>? options;
    protected override void OnInitialized()
    {
        base.OnInitialized();
        if (Value != null)
            options = FormBuilder.Create<UserPwd>().Build<UserPwd>(UI, Value);
    }

    public override Task<bool> OnPostAsync()
    {
        if (!(options?.Validate?.Invoke() ?? false))
        {
            return Task.FromResult(false);
        }
        
        return base.OnPostAsync();
    }
}

